﻿using Cyl.ImageControl;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Demo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        private BitmapImage _image;

        public BitmapImage Image
        {
            get { return _image; }
            set
            {
                _image = value;
                OnPropertyChanged(nameof(Image));
            }
        }
        private bool isRoiEnable;

        public bool IsRoiEnable
        {
            get { return isRoiEnable; }
            set
            {
                isRoiEnable = value;
                OnPropertyChanged(nameof(IsRoiEnable));
            }
        }
        private bool showCrosser;

        public bool ShowCrosser
        {
            get { return showCrosser; }
            set
            {
                showCrosser = value;
                OnPropertyChanged(nameof(ShowCrosser));
            }
        }
        private List<ROI> _rois = new();

        public List<ROI> ROIs
        {
            get { return _rois; }
            set
            {
                _rois = value;
                OnPropertyChanged(nameof(ROIs));
            }
        }

        private List<TextAnnotation> _textAnnotations = new();
        public List<TextAnnotation> TextAnnotations
        {
            get { return _textAnnotations; }
            set
            {
                _textAnnotations = value;
                OnPropertyChanged(nameof(TextAnnotations));
            }
        }

        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            Image = new BitmapImage(new Uri("catdog.png", UriKind.RelativeOrAbsolute));

            ROIs.Add(new CircleROI(new Point(60, 60), 50, Colors.LimeGreen));

            TextAnnotations.Add(new TextAnnotation()
            {
                Text = "你好",
                FontSize = 100,
                Position = new Point(100, 100)
            });
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var ttt = ROIs;
        }
    }
}